home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 6 / The Arsenal Files 6 (Arsenal Computer).ISO / prg_casm / jlvesa11.zip / JLVESA06.ASM < prev    next >
Assembly Source File  |  1995-11-14  |  3KB  |  151 lines

  1. ; This routine is part of VESA SVGA -library
  2. ;
  3. ; Copyright 1994 Johannes Lehtinen
  4. ; All rights reserved
  5.  
  6. model large,c
  7. p386
  8.  
  9. include "jlvesads.asm"
  10.  
  11. segment jlvesa06_TEXT USE16 'CODE'
  12. assume cs:jlvesa06_TEXT
  13.  
  14. ; void JVScreen_ClearAll(JVUByte color)
  15. ;
  16. ; Clears video memory to given color.
  17.  
  18. proc JVScreen_ClearAll far
  19.    public JVScreen_ClearAll
  20.  
  21.    push  bp
  22.    mov   bp,sp
  23.    push  di
  24.    push  ds
  25.    push  es
  26.  
  27.    mov   ax,JLVesa_Data
  28.    mov   ds,ax
  29.  
  30.    ; First move write window to the start of video memory if needed
  31.  
  32.    cmp   [ds:WAStart],0
  33.    je    short already_zero
  34.  
  35.    mov   bl,[ds:WWin]
  36.    xor   bh,bh
  37.    xor   dx,dx
  38.    call  [ds:PosFunc]
  39.    mov   [ds:WAStart],0
  40.  
  41.    ; EBX = Absolute address, AEX = Color used to clear
  42.  
  43. already_zero:
  44.    mov   al,[ss:bp+6]
  45.    shl   eax,8
  46.    mov   al,[ss:bp+6]
  47.    shl   eax,8
  48.    mov   al,[ss:bp+6]
  49.    shl   eax,8
  50.    mov   al,[ss:bp+6]
  51.    mov   bx,[ds:WWSeg]        ; ES = Window segment
  52.    mov   es,bx
  53.    xor   ebx,ebx
  54.    cld                        ; Direction forward
  55.  
  56.    ; Loop where the action takes place
  57.  
  58.    ; Check if there is whole block left
  59.  
  60. clr_loop:
  61.    mov   ecx,[ds:WAStart]
  62.    add   ecx,[ds:WSize]
  63.    cmp   [ds:Size],ecx
  64.    jbe   short last_block
  65.  
  66.    ; Copy one block
  67.  
  68.    mov   edi,ebx
  69.    sub   edi,[ds:WAStart]
  70.    mov   ecx,[ds:WSize]
  71.    sub   ecx,edi
  72.    shr   ecx,2
  73.    rep   stosd
  74.  
  75.    ; Take next block
  76.  
  77.    mov   ebx,[ds:WAStart]
  78.    add   ebx,[ds:WSize]
  79.  
  80.    ; Change window
  81.  
  82.    push  eax
  83.    mov   eax,ebx
  84.    mov   ecx,[ds:Granularity]
  85.    xor   edx,edx
  86.    div   ecx
  87.  
  88.    push  ebx
  89.    mov   dx,ax
  90.    xor   bh,bh
  91.    mov   bl,[ds:WWin]
  92.    push  ax
  93.    call  [ds:PosFunc]
  94.    xor   eax,eax
  95.    pop   ax
  96.    pop   ebx
  97.  
  98.    mul   ecx
  99.    mov   [ds:WAStart],eax
  100.  
  101.    pop   eax
  102.    jmp   short clr_loop
  103.  
  104.    ; Copy the last block
  105.  
  106.    ; Count where to start and how many bytes to write
  107.  
  108. last_block:
  109.    mov   edi,ebx
  110.    sub   edi,[ds:WAStart]
  111.  
  112.    mov   ecx,[ds:Size]
  113.    sub   ecx,ebx
  114.    dec   ecx
  115.    mov   dl,cl
  116.    shr   ecx,2
  117.  
  118.    rep   stosd
  119.    test  dl,2
  120.    jz    short not_2_left
  121.  
  122.    stosw
  123.  
  124. not_2_left:
  125.    test  dl,1
  126.    jz    short not_1_left
  127.  
  128.    stosb
  129.  
  130.    ; Memory cleared, set read window point to another window if necessary
  131.  
  132. not_1_left:
  133.    mov   al,[ds:WWin]
  134.    cmp   [ds:RWin],al
  135.    jne   short not_same_window
  136.  
  137.    mov   eax,[ds:WAStart]
  138.    mov   [ds:RAStart],eax
  139.  
  140. not_same_window:
  141.    pop   es
  142.    pop   ds
  143.    pop   di
  144.    pop   bp
  145.    retf
  146.  
  147. endp JVScreen_ClearAll
  148.  
  149. ends
  150.  
  151. end